import 'package:flutter/material.dart';
import 'package:get/get_state_manager/get_state_manager.dart';
import 'package:jinke/global/user/logic.dart';
import 'package:jinke/page/pro_list/subs/pro_open/subs/pro_open_step1/index.dart';
import 'package:jinke/utils/util.dart';

import 'name_field.dart';

class ProBrifeWidget extends GetView<ProOpenStep1Controller> {
  const ProBrifeWidget({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.symmetric(horizontal: 16.r, vertical: 10.r),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          BrnTextSelectFormItem(
            title: '项目专员:',
            isRequire: true,
            hint: '请选择项目专员，单选',
            value: controller.state.lead?.userName ??
                (UserController().state.user?.userName ?? ''),
            onTap: () {
              controller.actionLead();
            },
          ),
          Container(
            margin: EdgeInsets.only(top: 10.r),
            padding: EdgeInsets.symmetric(horizontal: gap15, vertical: gap10),
            decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.circular(4.r),
            ),
            child: Column(
              children: [
                NameField(
                  name: '项目名称',
                  placeholder: '请输入项目全称',
                  controller: controller.state.nameCtrl,
                ),
                Container(
                    height: 70.r,
                    alignment: Alignment.centerLeft,
                    decoration: const BoxDecoration(
                      border: Border(
                        bottom: BorderSide(
                          color: ColorsUtil.separator,
                        ),
                      ),
                    ),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                      children: [
                        Text.rich(
                          TextSpan(
                              text: '*',
                              style: TextStyle(
                                  color: ColorsUtil.red, fontSize: 16.sp),
                              children: [
                                TextSpan(
                                  text: '项目简称',
                                  style: TextStyle(
                                      color: ColorsUtil.title, fontSize: 16.sp),
                                ),
                                TextSpan(
                                  text:
                                      '  ${controller.state.comMod?.name ?? ''}${controller.state.buildCtrl.text}',
                                  style: TextStyle(
                                      color: ColorsUtil.title, fontSize: 16.sp),
                                ),
                              ]),
                        ),
                        Text(
                          '组成：企业简称+建设内容简称',
                          style: TextStyle(
                              color: ColorsUtil.content, fontSize: 14.sp),
                        )
                      ],
                    )),
                InkWell(
                  onTap: controller.actionChooseCom,
                  child: Container(
                    height: 50.r,
                    alignment: Alignment.centerLeft,
                    decoration: const BoxDecoration(
                      border: Border(
                        bottom: BorderSide(
                          color: ColorsUtil.separator,
                        ),
                      ),
                    ),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Text.rich(
                          TextSpan(
                              text: '*',
                              style: TextStyle(
                                  color: ColorsUtil.red, fontSize: 16.sp),
                              children: [
                                TextSpan(
                                  text: '企业简称',
                                  style: TextStyle(
                                      color: ColorsUtil.title, fontSize: 16.sp),
                                ),
                              ]),
                        ),
                        Text(
                          controller.state.comMod?.name ?? '请选择',
                          style: TextStyle(
                              color: ColorsUtil.content, fontSize: 14.sp),
                        )
                      ],
                    ),
                  ),
                ),
                Container(
                  height: 50.r,
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Text.rich(
                        TextSpan(
                            text: '*',
                            style: TextStyle(
                                color: ColorsUtil.red, fontSize: 16.sp),
                            children: [
                              TextSpan(
                                text: '建设内容',
                                style: TextStyle(
                                    color: ColorsUtil.title, fontSize: 16.sp),
                              )
                            ]),
                      ),
                      Icon(
                        Icons.keyboard_voice,
                        color: ColorsUtil.blue,
                        size: 20.r,
                      ),
                    ],
                  ),
                ),
                Container(
                  padding: EdgeInsets.all(gap15),
                  decoration: BoxDecoration(
                    color: ColorsUtil.bg,
                    borderRadius: BorderRadius.circular(4.r),
                  ),
                  child: TextField(
                    controller: controller.state.buildCtrl,
                    maxLength: 800,
                    maxLines: 4,
                    textAlignVertical: TextAlignVertical.top,
                    style: TextStyle(
                      color: ColorsUtil.title,
                      fontSize: 14.sp,
                    ),
                    decoration: InputDecoration(
                      fillColor: ColorsUtil.bg,
                      isCollapsed: false,
                      border: InputBorder.none,
                      hintText: '请输入项目建设内容',
                      hintStyle: TextStyle(
                        color: ColorsUtil.placeholder,
                        fontSize: 14.sp,
                      ),
                    ),
                    onChanged: (value) {
                      controller.update();
                    },
                  ),
                )
              ],
            ),
          ),
        ],
      ),
    );
  }
}
